package com.qs.cwams.controller;


import com.qs.common.framework.dto.PageResult;
import com.qs.common.framework.dto.QsResult;
import com.qs.common.framework.dto.Query;
import com.qs.cwams.pojo.view.*;
import com.qs.cwams.service.ApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author suncheng
 */
@RestController
@RequestMapping("/flow")
public class FlowController {

    @Autowired
    private ApplyService applyService;

    /**
     * 查询申请
     * @param applyQuery
     * @return
     */
    @PostMapping("/query/apply")
    public QsResult<PageResult<ApplyVO>> queryApply(@RequestBody Query<ApplyVO> applyQuery) {
        PageResult<ApplyVO> result = applyService.queryApply(applyQuery.getParam(), applyQuery.getPage());
        return QsResult.ok().setResult(result);
    }

    /**
     * 申请
     * @param applyVO
     * @return
     */
    @PostMapping("/apply")
    public QsResult apply(@RequestBody ApplyVO applyVO){
        return applyService.apply(applyVO);
    }

    /**
     * 审批
     * @param applyVO
     * @return
     */
    @PostMapping("/approve")
    public QsResult approve(@RequestBody ApplyVO applyVO){
        return applyService.approve(applyVO);
    }
}
